package com.magnificent.atlantis.server.handler;

import java.util.HashMap;
import java.util.Map;

/**
 * User: Babanin
 * Date: 25.03.2009
 * Time: 20:04:35
 */
public abstract class Handler {
    private String commandName;

    private static Map<String, Handler> handlers = new HashMap<String, Handler>();

    protected Handler(String commandName) {
        handlers.put(commandName, this);
    }

    public String getCommandName() {
        return commandName;
    }

    public void setCommandName(String commandName) {
        this.commandName = commandName;
    }

    public static void handle(String commandName, String... parameters) {
        Handler handler = handlers.get(commandName);

        if (handler != null) {
            handler.handle(parameters);
        }
    }

    public abstract void handle(String... parameters);
}
